/*
 * @ClassName show_test.dart
 * @Description 弹窗测试页面
 * @Author SuPeiSen
 * @Date 2020/7/20 16:40
 */

import 'package:flutter/material.dart';
import 'package:flutter_su/common/fun.dart';
import 'package:flutter_su/common/show.dart';
import 'package:flutter_su/pages/test/common_widget.dart';

class ShowTest extends StatefulWidget {
  @override
  _ShowTestState createState() => _ShowTestState();
}

class _ShowTestState extends State<ShowTest> with CommonTestWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("弹窗"),
        centerTitle: true,
        backgroundColor: Colors.black,
      ),
      backgroundColor: Colors.black,
      body: _body(),
    );
  }

  Widget _body() {
    return Container(
      width: double.infinity,
      child: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            _easyLoading(),
          ],
        ),
      ),
    );
  }


  Widget _easyLoading() {
    return Column(
      children: <Widget>[
        title("EasyLoading"),
        _easyLoadingChild(),
        title("OtherLoading"),
        _otherLoading(),
        title("ToastLoading"),
        _toastLoading(),
      ],
    );
  }

  Widget _easyLoadingChild(){
    return Wrap(
      spacing: 10,
      children: <Widget>[

        RaisedButton(
          child: Text("showLoading"),
          onPressed: () {
            Show.loading(bgColor: Colors.white, textColor: Colors.black, msg: "请稍等");
          },
        ),

        RaisedButton(
          child: Text("showText"),
          onPressed: () {
            Show.showMsg("请稍等");
          },
        ),

        RaisedButton(
          child: Text("msgBySuccess"),
          onPressed: () {
            Show.showMsgBySuccess("success");
          },
        ),

        RaisedButton(
          child: Text("msgByError"),
          onPressed: () {
            Show.showMsgByError("error");
          },
        ),

        RaisedButton(
          child: Text("showSuccess"),
          onPressed: () {
//            Show.success(msg: "成功弹窗");
            Show.success(msg: "成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗成功弹窗");
          },
        ),

        RaisedButton(
          child: Text("showError"),
          onPressed: () {
            Show.error(msg: "错误弹窗");
          },
        ),

        RaisedButton(
          child: Text("showWarn"),
          onPressed: () {
            Show.warn(msg: "提示弹窗");
          },
        ),

        RaisedButton(
          child: Text("showLoading"),
          onPressed: () {
            Show.loading(autoDismiss: true);
          },
        ),

        RaisedButton(
          child: Text("showText"),
          onPressed: () {
//            Show.toast(msg: "文字弹窗");
          },
        ),
      ],
    );
  }

  Widget _otherLoading() {
    return Column(
      children: <Widget>[
        _otherLoadingChild(),
      ],
    );
  }

  Widget _otherLoadingChild(){
    return Wrap(
      children: <Widget>[
        RaisedButton(
          child: Text("底部弹窗"),
          onPressed: () {
            Show.showBottomSheet(msg: "132456");
          },
        ),
      ],
    );
  }

  Widget _toastLoading() {
    return Column(
      children: <Widget>[
        _toastLoadingChild(),
      ],
    );
  }

  Widget _toastLoadingChild(){
    return Wrap(
      spacing: 10,
      children: <Widget>[
        RaisedButton(
          child: Text("toastText"),
          onPressed: () {
            Toast.showText(msg: "自定义弹窗", top: 150, bgColor: Colors.blue);
          },
        ),

        RaisedButton(
          child: Text("removeToast"),
          onPressed: () {
            Toast.removeOverlay();
          }
        ),
//        RaisedButton(
//          child: Text("上到下"),
//          onPressed: () {
//          },
//        ),
      ],
    );
  }

}
